function  show(i){
    var phone = document.getElementById("phone").style;
    var mail = document.getElementById("mail").style;
    var phoneLogin = document.getElementById("phoneLogin").style;
    var mailLogin = document.getElementById("emailLogin").style;
    if(i == 1){
        mail.display="none";
        phone.display="block";
        phoneLogin.backgroundColor="#148be4";
        mailLogin.backgroundColor="white";
    }else{
        phone.display="none";
        mail.display="block";
        phoneLogin.backgroundColor="white";
        mailLogin.backgroundColor="#148be4";
    }
}

function sendCode(){
    var button = document.getElementById("sendMail");
    var email = document.getElementById("email").value;
    var xmlhttp = new XMLHttpRequest();
    var wait = 120;
    if(email.length > 0){
        if(button.innerHTML == "发送"){
            xmlhttp.open("POST", "/send?mail="+email, false);
            xmlhttp.send();
            if(xmlhttp.responseText){
                function countTime(){
                    wait --;
                    if(wait == -1){
                        clearInterval(stop);
                        xmlhttp.open("POST", "clear",false);
                        xmlhttp.send();
                        button.innerHTML = "发送";
                    }else{
                        button.innerHTML = wait + "秒";
                    }
                }
                var stop = setInterval(countTime, 1000);
            }
        }
    }
}